package com.webvihar.access2db.restapi;

import com.webvihar.common.utils.Base64Coder;


/**
 * @author Viswanath Kumar sandu
 * 
 */
public class A2DbUrlBuilder {

//	private static final String baseurl = "http://10.0.2.2:8080/Access2DbRestService/rest";
	// Home network
	private static final String baseurl = "http://10.0.2.2:8080/Access2DbRestService/rest";
	// office network
//	private static final String baseurl = "http://10.0.1.153:8080/Access2DbRestService/rest";
	// office network
//	private static final String baseurl = "http://10.0.1.245:8080/Access2DbRestService/rest";
	
    public static final String getRunQuery(Boolean encoded, String host, String port, String username, String password, String dbname, String query) {
    	if(encoded) {
    		return String.format("%s/runQuery?encoded=%s&host=%s&port=%s&username=%s&password=%s&dbname=%s&query=%s",baseurl, encoded, Base64Coder.encodeString(host), Base64Coder.encodeString(port), Base64Coder.encodeString(username), Base64Coder.encodeString(password), Base64Coder.encodeString(dbname), Base64Coder.encodeString(query));
    	} else {
    		return String.format("%s/runQuery?encoded=%s&host=%s&port=%s&username=%s&password=%s&dbname=%s&query=%s",baseurl, encoded, host, port, username, password, dbname, query);
    	}
    }
    
    public static final String getRunSelectQuery(Boolean encoded, String host, String port, String username, String password, String dbname, String query) {
    	if(encoded) {
    		return String.format("%s/runSelectQuery?encoded=%s&host=%s&port=%s&username=%s&password=%s&dbname=%s&query=%s",baseurl, encoded, Base64Coder.encodeString(host), Base64Coder.encodeString(port), Base64Coder.encodeString(username), Base64Coder.encodeString(password), Base64Coder.encodeString(dbname), Base64Coder.encodeString(query));
    	} else {
    		return String.format("%s/runSelectQuery?encoded=%s&host=%s&port=%s&username=%s&password=%s&dbname=%s&query=%s",baseurl, encoded, host, port, username, password, dbname, query);
    	}
    }
    
    public static final String getRunShowQuery(Boolean encoded, String host, String port, String username, String password, String dbname, String query) {
    	if(encoded) {
    		return String.format("%s/runShowQuery?encoded=%s&host=%s&port=%s&username=%s&password=%s&dbname=%s&query=%s",baseurl, encoded, Base64Coder.encodeString(host), Base64Coder.encodeString(port), Base64Coder.encodeString(username), Base64Coder.encodeString(password), Base64Coder.encodeString(dbname), Base64Coder.encodeString(query));
    	} else {
    		return String.format("%s/runShowQuery?encoded=%s&host=%s&port=%s&username=%s&password=%s&dbname=%s&query=%s",baseurl, encoded, host, port, username, password, dbname, query);
    	}
    }
}
